package com.edisoncgh.service.impl;

import com.edisoncgh.dao.LoanMapper;
import com.edisoncgh.pojo.Loan;
import com.edisoncgh.pojo.LoanExample;
import com.edisoncgh.service.LoanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class LoanServiceImpl implements LoanService {
    private LoanMapper loanMapper;

    @Autowired
    public void setLoanMapper(LoanMapper loanMapper){
        this.loanMapper = loanMapper;
    }
    @Override
    public boolean addLoan(Loan loan) {
        return loanMapper.insert(loan)>0;
    }

    @Override
    public List<Loan> findAllLoan() {
        LoanExample loanExample = new LoanExample();
        return loanMapper.selectByExample(loanExample);
    }

    @Override
    public boolean deleteLoan(Integer loanNo, String ISBN) {
        return loanMapper.deleteByPrimaryKey(loanNo, ISBN)>0;
    }
}
